3.10 \(\int (a+b \tan (c+d x))^2 (B \tan (c+d x)+C \tan ^2(c+d x)) \, dx\)

Optimal. Leaf size=112 \[ -\frac{\left (a^2 B-2 a b C-b^2 B\right ) \log (\cos (c+d x))}{d}-x \left (a^2 C+2 a b B-b^2 C\right )+\frac{b (a B-b C) \tan (c+d x)}{d}+\frac{B (a+b \tan (c+d x))^2}{2 d}+\frac{C (a+b \tan (c+d x))^3}{3 b d} \]

[Out]

-((2*a*b*B + a^2*C - b^2*C)*x) - ((a^2*B - b^2*B - 2*a*b*C)*Log[Cos[c + d*x]])/d + (b*(a*B - b*C)*Tan[c + d*x]
)/d + (B*(a + b*Tan[c + d*x])^2)/(2*d) + (C*(a + b*Tan[c + d*x])^3)/(3*b*d)

________________________________________________________________________________________

Rubi [A]  time = 0.111664, antiderivative size = 112, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 4, integrand size = 32, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.125, Rules used = {3630, 3528, 3525, 3475} \[ -\frac{\left (a^2 B-2 a b C-b^2 B\right ) \log (\cos (c+d x))}{d}-x \left (a^2 C+2 a b B-b^2 C\right )+\frac{b (a B-b C) \tan (c+d x)}{d}+\frac{B (a+b \tan (c+d x))^2}{2 d}+\frac{C (a+b \tan (c+d x))^3}{3 b d} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[c + d*x])^2*(B*Tan[c + d*x] + C*Tan[c + d*x]^2),x]

[Out]

-((2*a*b*B + a^2*C - b^2*C)*x) - ((a^2*B - b^2*B - 2*a*b*C)*Log[Cos[c + d*x]])/d + (b*(a*B - b*C)*Tan[c + d*x]
)/d + (B*(a + b*Tan[c + d*x])^2)/(2*d) + (C*(a + b*Tan[c + d*x])^3)/(3*b*d)

Rule 3630

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (
f_.)*(x_)]^2), x_Symbol] :> Simp[(C*(a + b*Tan[e + f*x])^(m + 1))/(b*f*(m + 1)), x] + Int[(a + b*Tan[e + f*x])
^m*Simp[A - C + B*Tan[e + f*x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0]
&&  !LeQ[m, -1]

Rule 3528

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(d
*(a + b*Tan[e + f*x])^m)/(f*m), x] + Int[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x
], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && GtQ[m, 0]

Rule 3525

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[(b*d*Tan[e + f*x])/f, x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int (a+b \tan (c+d x))^2 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx &=\frac{C (a+b \tan (c+d x))^3}{3 b d}+\int (a+b \tan (c+d x))^2 (-C+B \tan (c+d x)) \, dx\\ &=\frac{B (a+b \tan (c+d x))^2}{2 d}+\frac{C (a+b \tan (c+d x))^3}{3 b d}+\int (a+b \tan (c+d x)) (-b B-a C+(a B-b C) \tan (c+d x)) \, dx\\ &=-\left (2 a b B+a^2 C-b^2 C\right ) x+\frac{b (a B-b C) \tan (c+d x)}{d}+\frac{B (a+b \tan (c+d x))^2}{2 d}+\frac{C (a+b \tan (c+d x))^3}{3 b d}+\left (a^2 B-b^2 B-2 a b C\right ) \int \tan (c+d x) \, dx\\ &=-\left (2 a b B+a^2 C-b^2 C\right ) x-\frac{\left (a^2 B-b^2 B-2 a b C\right ) \log (\cos (c+d x))}{d}+\frac{b (a B-b C) \tan (c+d x)}{d}+\frac{B (a+b \tan (c+d x))^2}{2 d}+\frac{C (a+b \tan (c+d x))^3}{3 b d}\\ \end{align*}

Mathematica [C]  time = 1.78949, size = 172, normalized size = 1.54 \[ \frac{3 (a B+b C) \left (-2 b^2 \tan (c+d x)+i \left ((a+i b)^2 \log (-\tan (c+d x)+i)-(a-i b)^2 \log (\tan (c+d x)+i)\right )\right )+3 B \left (6 a b^2 \tan (c+d x)+(-b+i a)^3 \log (-\tan (c+d x)+i)-(b+i a)^3 \log (\tan (c+d x)+i)+b^3 \tan ^2(c+d x)\right )+2 C (a+b \tan (c+d x))^3}{6 b d} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[c + d*x])^2*(B*Tan[c + d*x] + C*Tan[c + d*x]^2),x]

[Out]

(2*C*(a + b*Tan[c + d*x])^3 + 3*(a*B + b*C)*(I*((a + I*b)^2*Log[I - Tan[c + d*x]] - (a - I*b)^2*Log[I + Tan[c
+ d*x]]) - 2*b^2*Tan[c + d*x]) + 3*B*((I*a - b)^3*Log[I - Tan[c + d*x]] - (I*a + b)^3*Log[I + Tan[c + d*x]] +
6*a*b^2*Tan[c + d*x] + b^3*Tan[c + d*x]^2))/(6*b*d)

________________________________________________________________________________________

Maple [A]  time = 0.012, size = 199, normalized size = 1.8 \begin{align*}{\frac{{b}^{2}C \left ( \tan \left ( dx+c \right ) \right ) ^{3}}{3\,d}}+{\frac{B \left ( \tan \left ( dx+c \right ) \right ) ^{2}{b}^{2}}{2\,d}}+{\frac{C \left ( \tan \left ( dx+c \right ) \right ) ^{2}ab}{d}}+2\,{\frac{Bab\tan \left ( dx+c \right ) }{d}}+{\frac{C\tan \left ( dx+c \right ){a}^{2}}{d}}-{\frac{{b}^{2}C\tan \left ( dx+c \right ) }{d}}+{\frac{{a}^{2}B\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }{2\,d}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ){b}^{2}B}{2\,d}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) Cab}{d}}-2\,{\frac{B\arctan \left ( \tan \left ( dx+c \right ) \right ) ab}{d}}-{\frac{C\arctan \left ( \tan \left ( dx+c \right ) \right ){a}^{2}}{d}}+{\frac{C\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{2}}{d}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x)

[Out]

1/3/d*b^2*C*tan(d*x+c)^3+1/2/d*B*tan(d*x+c)^2*b^2+1/d*C*tan(d*x+c)^2*a*b+2/d*B*a*b*tan(d*x+c)+1/d*C*tan(d*x+c)
*a^2-b^2*C*tan(d*x+c)/d+1/2/d*a^2*B*ln(1+tan(d*x+c)^2)-1/2/d*ln(1+tan(d*x+c)^2)*b^2*B-1/d*ln(1+tan(d*x+c)^2)*C
*a*b-2/d*B*arctan(tan(d*x+c))*a*b-1/d*C*arctan(tan(d*x+c))*a^2+1/d*C*arctan(tan(d*x+c))*b^2

________________________________________________________________________________________

Maxima [A]  time = 1.7285, size = 162, normalized size = 1.45 \begin{align*} \frac{2 \, C b^{2} \tan \left (d x + c\right )^{3} + 3 \,{\left (2 \, C a b + B b^{2}\right )} \tan \left (d x + c\right )^{2} - 6 \,{\left (C a^{2} + 2 \, B a b - C b^{2}\right )}{\left (d x + c\right )} + 3 \,{\left (B a^{2} - 2 \, C a b - B b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 6 \,{\left (C a^{2} + 2 \, B a b - C b^{2}\right )} \tan \left (d x + c\right )}{6 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="maxima")

[Out]

1/6*(2*C*b^2*tan(d*x + c)^3 + 3*(2*C*a*b + B*b^2)*tan(d*x + c)^2 - 6*(C*a^2 + 2*B*a*b - C*b^2)*(d*x + c) + 3*(
B*a^2 - 2*C*a*b - B*b^2)*log(tan(d*x + c)^2 + 1) + 6*(C*a^2 + 2*B*a*b - C*b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Fricas [A]  time = 1.32028, size = 275, normalized size = 2.46 \begin{align*} \frac{2 \, C b^{2} \tan \left (d x + c\right )^{3} - 6 \,{\left (C a^{2} + 2 \, B a b - C b^{2}\right )} d x + 3 \,{\left (2 \, C a b + B b^{2}\right )} \tan \left (d x + c\right )^{2} - 3 \,{\left (B a^{2} - 2 \, C a b - B b^{2}\right )} \log \left (\frac{1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 6 \,{\left (C a^{2} + 2 \, B a b - C b^{2}\right )} \tan \left (d x + c\right )}{6 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="fricas")

[Out]

1/6*(2*C*b^2*tan(d*x + c)^3 - 6*(C*a^2 + 2*B*a*b - C*b^2)*d*x + 3*(2*C*a*b + B*b^2)*tan(d*x + c)^2 - 3*(B*a^2
- 2*C*a*b - B*b^2)*log(1/(tan(d*x + c)^2 + 1)) + 6*(C*a^2 + 2*B*a*b - C*b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Sympy [A]  time = 1.58424, size = 194, normalized size = 1.73 \begin{align*} \begin{cases} \frac{B a^{2} \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 2 B a b x + \frac{2 B a b \tan{\left (c + d x \right )}}{d} - \frac{B b^{2} \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac{B b^{2} \tan ^{2}{\left (c + d x \right )}}{2 d} - C a^{2} x + \frac{C a^{2} \tan{\left (c + d x \right )}}{d} - \frac{C a b \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{d} + \frac{C a b \tan ^{2}{\left (c + d x \right )}}{d} + C b^{2} x + \frac{C b^{2} \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac{C b^{2} \tan{\left (c + d x \right )}}{d} & \text{for}\: d \neq 0 \\x \left (a + b \tan{\left (c \right )}\right )^{2} \left (B \tan{\left (c \right )} + C \tan ^{2}{\left (c \right )}\right ) & \text{otherwise} \end{cases} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))**2*(B*tan(d*x+c)+C*tan(d*x+c)**2),x)

[Out]

Piecewise((B*a**2*log(tan(c + d*x)**2 + 1)/(2*d) - 2*B*a*b*x + 2*B*a*b*tan(c + d*x)/d - B*b**2*log(tan(c + d*x
)**2 + 1)/(2*d) + B*b**2*tan(c + d*x)**2/(2*d) - C*a**2*x + C*a**2*tan(c + d*x)/d - C*a*b*log(tan(c + d*x)**2
+ 1)/d + C*a*b*tan(c + d*x)**2/d + C*b**2*x + C*b**2*tan(c + d*x)**3/(3*d) - C*b**2*tan(c + d*x)/d, Ne(d, 0)),
 (x*(a + b*tan(c))**2*(B*tan(c) + C*tan(c)**2), True))

________________________________________________________________________________________

Giac [B]  time = 3.21836, size = 2037, normalized size = 18.19 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="giac")

[Out]

-1/6*(6*C*a^2*d*x*tan(d*x)^3*tan(c)^3 + 12*B*a*b*d*x*tan(d*x)^3*tan(c)^3 - 6*C*b^2*d*x*tan(d*x)^3*tan(c)^3 + 3
*B*a^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*
tan(d*x)*tan(c) + 1))*tan(d*x)^3*tan(c)^3 - 6*C*a*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*t
an(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^3*tan(c)^3 - 3*B*b^2*log(4*(tan(c)
^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)
)*tan(d*x)^3*tan(c)^3 - 18*C*a^2*d*x*tan(d*x)^2*tan(c)^2 - 36*B*a*b*d*x*tan(d*x)^2*tan(c)^2 + 18*C*b^2*d*x*tan
(d*x)^2*tan(c)^2 - 6*C*a*b*tan(d*x)^3*tan(c)^3 - 3*B*b^2*tan(d*x)^3*tan(c)^3 - 9*B*a^2*log(4*(tan(c)^2 + 1)/(t
an(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)
^2*tan(c)^2 + 18*C*a*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 +
 tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^2*tan(c)^2 + 9*B*b^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2
- 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^2*tan(c)^2 + 6*C*a
^2*tan(d*x)^3*tan(c)^2 + 12*B*a*b*tan(d*x)^3*tan(c)^2 - 6*C*b^2*tan(d*x)^3*tan(c)^2 + 6*C*a^2*tan(d*x)^2*tan(c
)^3 + 12*B*a*b*tan(d*x)^2*tan(c)^3 - 6*C*b^2*tan(d*x)^2*tan(c)^3 + 18*C*a^2*d*x*tan(d*x)*tan(c) + 36*B*a*b*d*x
*tan(d*x)*tan(c) - 18*C*b^2*d*x*tan(d*x)*tan(c) - 6*C*a*b*tan(d*x)^3*tan(c) - 3*B*b^2*tan(d*x)^3*tan(c) + 6*C*
a*b*tan(d*x)^2*tan(c)^2 + 3*B*b^2*tan(d*x)^2*tan(c)^2 - 6*C*a*b*tan(d*x)*tan(c)^3 - 3*B*b^2*tan(d*x)*tan(c)^3
+ 2*C*b^2*tan(d*x)^3 + 9*B*a^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*ta
n(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*tan(c) - 18*C*a*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(
c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*tan(c) - 9*B*
b^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan
(d*x)*tan(c) + 1))*tan(d*x)*tan(c) - 12*C*a^2*tan(d*x)^2*tan(c) - 24*B*a*b*tan(d*x)^2*tan(c) + 18*C*b^2*tan(d*
x)^2*tan(c) - 12*C*a^2*tan(d*x)*tan(c)^2 - 24*B*a*b*tan(d*x)*tan(c)^2 + 18*C*b^2*tan(d*x)*tan(c)^2 + 2*C*b^2*t
an(c)^3 - 6*C*a^2*d*x - 12*B*a*b*d*x + 6*C*b^2*d*x + 6*C*a*b*tan(d*x)^2 + 3*B*b^2*tan(d*x)^2 - 6*C*a*b*tan(d*x
)*tan(c) - 3*B*b^2*tan(d*x)*tan(c) + 6*C*a*b*tan(c)^2 + 3*B*b^2*tan(c)^2 - 3*B*a^2*log(4*(tan(c)^2 + 1)/(tan(d
*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)) + 6*C*a*b*lo
g(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*
tan(c) + 1)) + 3*B*b^2*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 +
 tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1)) + 6*C*a^2*tan(d*x) + 12*B*a*b*tan(d*x) - 6*C*b^2*tan(d*x) + 6*C*a^2*tan(
c) + 12*B*a*b*tan(c) - 6*C*b^2*tan(c) + 6*C*a*b + 3*B*b^2)/(d*tan(d*x)^3*tan(c)^3 - 3*d*tan(d*x)^2*tan(c)^2 +
3*d*tan(d*x)*tan(c) - d)